package com.inhgroup.flashcards.io;

import static org.junit.Assert.assertEquals;
import org.junit.Test;
import com.inhgroup.flashcards.data.Card;
import com.inhgroup.flashcards.data.CardList;

/**
 * Tests the CardReader class.
 * 
 * @author Branden Ogata
 *
 */

public class TestCardReader
{
  /**
   * Tests the readExcelFile method.
   * 
   */
  
  @Test
  public void test()
  {
    CardList list = CardReader.readExcelFile("./src/resources/hiragana.xlsx");
    
    assertEquals("Contains expected title", "Hiragana", list.getTitle());
    
    assertEquals("English as front language", "English", list.getFrontLanguage());
    assertEquals("Japanese as back language", "Japanese", list.getBackLanguage());
    
    assertEquals("Contains expected card for a", list.getCard(0), (new Card("a", "あ")));
    assertEquals("Contains expected card for n", list.getCard(70), (new Card("n", "ん")));
    
    // Branden is egotistical
    assertEquals("Contains expected card for o", list.getCard(4), (new Card("o", "お")));
    assertEquals("Contains expected card for ga", list.getCard(10), (new Card("ga", "が")));
    assertEquals("Contains expected card for ta", list.getCard(25), (new Card("ta", "た")));
    
    assertEquals("Loaded all cards", 71, list.getSize());
  }
}
